<?php

if (!defined('BASEPATH'))
    exit('No direct script access allowed');

class Detail extends CI_Controller {

    function __construct() { //inisialisasi library dan helper yang perlu di load
        parent::__construct();
        $this->load->helper('form');
        $this->load->model('simades');
        $log = $this->session->all_userdata();
        if (!isset($log) || $log['login'] != TRUE) {
            redirect('');
        }
    }

    function index() {
        $data['title'] = 'Penduduk';
        $data['isi'] = $this->simades->get_pndk();
        $this->load->view('penduduk', $data);
    }

    function nik() {
        $nik = $this->uri->segment(3);
        if ($data['pndk'] = $this->simades->get_pndk_nik($nik)) {
            $data['pndk'] = $this->simades->get_pndk_nik($nik);
        } else {
            $data['pndk'] = null;
        }
        $data['title'] = 'Penduduk Detail';
        $data['username'] = $this->session->userdata('username');
        if ($data['isi'] = $this->simades->get_sys()) {
            $data['isi'] = $this->simades->get_sys();
        } else {
            $data['isi'] = array();
        }
        $this->load->view('template/head', $data);
        $this->load->view('petugas/menu');
        $this->load->view('petugas/detail_nik', $data);
        $this->load->view('template/foot');
    }

    function del_nik() {
        $nik = $this->uri->segment(3);
        $this->simades->del_nik($nik);
        redirect('petugas/penduduk');
    }

    function kk() {
        $kk = $this->uri->segment(3);
        if ($data['pdk'] = $this->simades->get_pndk_kk($kk)) {
            $data['pdk'] = $this->simades->get_pndk_kk($kk);
        } else {
            $data['pdk'] = array();
        }
        $data['title'] = 'Detail Kartu keluarga';
        $data['username'] = $this->session->userdata('username');
        $data['no_kk'] = $kk;
        if ($data['isi'] = $this->simades->get_sys()) {
            $data['isi'] = $this->simades->get_sys();
        } else {
            $data['isi'] = array();
        }
        if ($data['kk'] = $this->simades->get_kk()) {
            $data['kk'] = $this->simades->get_kk();
        } else {
            $data['kk'] = array();
        }
        $this->load->view('template/head', $data);
        $this->load->view('petugas/menu');
        $this->load->view('petugas/detail_kk', $data);
        $this->load->view('template/foot');
    }

}

?>
